Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Jan 8, 2026

Cherry-picked from #59580

#59580)

When restoring a view to a different database, the current
implementation incorrectly replaces **all** database names in the view
definition with the target database name. This breaks cross-database
references.

**Example:**
- Original: `view_db` has a view referencing tables from both `base_db`
and `view_db`
```sql
  SELECT * FROM `internal`.`base_db`.`table1` 
  JOIN `internal`.`view_db`.`table2`
```
  - After restore to `restore_db` (BEFORE this PR):
```sql
  SELECT * FROM `internal`.`restore_db`.`table1`  -- ❌ Wrong! Should be base_db
  JOIN `internal`.`restore_db`.`table2`           -- ✅ Correct
```
  - After restore to `restore_db` (AFTER this PR):
```sql
  SELECT * FROM `internal`.`base_db`.`table1`     -- ✅ Correct! Preserved
  JOIN `internal`.`restore_db`.`table2`           -- ✅ Correct
```
  **Root Cause:**
The regex pattern `(?<=\`internal\`\\.\`)([^\`]+)(?=\`\\.\`)` matches
**any** database name, not just the source database name.
@github-actions github-actions bot requested a review from yiguolei as a code owner January 8, 2026 02:41
@hello-stephen
Copy link
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@dataroaring dataroaring closed this Jan 8, 2026
@dataroaring dataroaring reopened this Jan 8, 2026
@hello-stephen
Copy link
Contributor

run buildall

@Ryan19929
Copy link
Contributor

run feut

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 100.00% (2/2) 🎉
Increment coverage report
Complete coverage report

@Ryan19929
Copy link
Contributor

run cloud_p0

1 similar comment
@Ryan19929
Copy link
Contributor

run cloud_p0

@yiguolei
Copy link
Contributor

skip buildall

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Jan 12, 2026
@github-actions
Copy link
Contributor Author

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Contributor Author

PR approved by anyone and no changes requested.

@yiguolei yiguolei merged commit 1c27a65 into branch-4.0 Jan 12, 2026
28 of 31 checks passed
@github-actions github-actions bot deleted the auto-pick-59580-branch-4.0 branch January 12, 2026 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants